// Profiler
// (c) jimon game studio

#ifndef JEH_IPROFILER
#define JEH_IPROFILER

#include "jeUnknown.h"
#include "jeSingleton.h"
#include "jeStl.h"

namespace je
{
	namespace core
	{
		//! Profiler
		class IProfiler:public je::jeUnknown
		{
		public:
			//! Destructor
			virtual ~IProfiler()
			{
			}

			//! Section Struct
			struct ProfileSection
			{
				u1 Open;
				jeStringc Name;
				f32 WorkTime;
				f32 OpenTime;

				//! Constructor
				ProfileSection()
					:Open(false),WorkTime(0.0f),OpenTime(0.0f)
				{
				}
			};

			//! Sections List Type
			typedef jeList<ProfileSection*> SectionsListType;

			// Return Sections List
			virtual SectionsListType & GetSections() = 0;

			//! Begin Section
			virtual void BeginSection(jeStringc Name) = 0;

			//! End Section
			virtual void EndSection(jeStringc Name) = 0;

			//! Set Auto Delete (by default, profiler delete all sections than open more than 5 secs)
			virtual void SetAutoDelete(u1 Enable = true,f32 DeleteTime = 5000.0f) = 0;

			//! Loop Tick, needed only for low-level work, if you use IApplication - dont call this
			virtual void LoopTick() = 0;
		};

		DECLARE_SINGLETON_E(JE_ENGINE_FUNCTION_API,JE_ENGINE_FUNCTION_CALL,Profiler)
	}
}

// Enesea Profile Begin Section No Debug
#define JEP_BEG_NOD(__Name) je::core::GetProfiler()->BeginSection(__Name);

// Enesea Profile End Section No Debug
#define JEP_END_NOD(__Name) je::core::GetProfiler()->EndSection(__Name);


#ifdef JE_DEBUG
	#define JEP_BEG(__Name) JEP_BEG_NOD(__Name)
	#define JEP_END(__Name) JEP_END_NOD(__Name)
#else
	#define JEP_BEG(__Name)
	#define JEP_END(__Name)
#endif

#endif
